﻿@using Model.WeiXin.DTO
@using Model.WXshopBuiness.Enum
@using Model.WXshopBuiness;
@using Xproject.Util
@{
    string Domain = CommonHelper.GetAppSettings("Domain");
    Layout = "~/Views/Shared/_JSlayout.cshtml";
    ZXUserInfoModel basicinfo = (ZXUserInfoModel)ViewBag.basicInfo;
   
}
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
    <title>分润</title>
    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/css/iscroll.css" rel="stylesheet" />
    <link href="~/Content/css/shop/home.css" rel="stylesheet" />
    <link href="http://at.alicdn.com/t/font_l6a0fwucxvzehfr.css" rel="stylesheet" type="text/css" />
    <style>
        body {
            background: #5f3b8e;
        }

        .item img {
            width: 100%;
            height: 180px;
        }

        .carousel-inner > .item > a > img {
            display: block;
            max-width: 100%;
            line-height: 1;
        }

        .textover {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 1.6rem;
        }

        .divmoney {
            color: #fe6e12;
            font-size: 1.457em;
            display: block;
            font-family: '微软雅黑';
            float: left;
        }

        .divqisong {
            display: block;
            margin-top: 1rem;
            margin-left: 7rem;
            font-size: 0.857em;
        }

        .bianjie {
            padding-right: 15px;
            padding-left: 15px;
            margin-right: auto;
            margin-left: auto;
        }

        .browserHistory {
            background: #fff;
            margin-bottom: 5.571em;
        }

        #thelist td {
            font-size: 1em;
            padding:5px;
        }

        #thelist tr:nth-child(1n) {
            background: #ffffff;
        }

        #thelist tr:nth-child(2n) {
            background: #eeeeee;
        }

        .personinfo {
            float: left;
            margin-left: 0.5rem;
            margin-top: 0.5rem;
            color: white;
        }

            .personinfo p {
                font-size: 1.2em;
            }
        .active {
            color: #246fc0;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div class="zhang">
        <div class="container">

            <div class="tou_x">
                <a href="#">
                    <div style="height: 50px;width: 50px;float: left;margin-top: 4px;padding-top: 10px;">
                        <img class="iconfont icon-touxiang" src="@basicinfo.HeadUrl" style="width:50px;height:50px;border-radius: 25px;" />
                    </div>
                </a>
                <div class="personinfo">
                    <p style="margin-bottom:2px;">@basicinfo.NickName</p>
                    <p style="margin-bottom:2px;">用户编码：@basicinfo.UserCode</p>
                    <p style="margin-bottom:2px;">手机号：@basicinfo.Mobile</p>
                </div>
            </div>
        </div>
    </div>
    <div style="display:block;height:2em;background-color:red;color:#f9e807;">

        <div style="display:inline-block;float:left;width:50%;height:2em;">
            <label style="font-size: 1.3em;">可提现：￥0元</label>
        </div>
        <div style="display:inline-block;height:2em;">
            <label style="font-size: 1.3em;">已提现：￥@(basicinfo.HaveEarnMoney.Value)元</label>
        </div>
    </div>
    
    <div id="wrapper">
        <div id="scroller">
            <div id="pullDown">
                <span class="pullDownIcon"></span>
                <span class="pullDownLabel">下拉刷新...</span>
            </div>

            <div class="browserHistory " style="margin-bottom:0px;margin-top: 2.8em ">
                <div style="display:block;width:100%;height:1.6em;">
                    <div style="display:inline-block;float:left;width:22%" class=" @(ViewBag.state==0?"active":"")">
                        <a style="margin-left:10px;"  href="@(Domain+"/Wallet/FenRunList?state=0")">待提现</a>
                    </div>
                    <div style="display:inline-block;width:22%" class=" @(ViewBag.state==5?"active":"")" >
                        <a style="margin-left:10px;"   href="@(Domain+"/Wallet/FenRunList?state=5")">审核中</a>
                    </div>
                    <div style="display:inline-block;width:22%"  class=" @(ViewBag.state==10?"active":"")">
                        <a  style="margin-left:10px;"  href="@(Domain+"/Wallet/FenRunList?state=10")">已提现</a>
                    </div>
                    <div style="display:inline-block;width:22%" class=" @(ViewBag.state==4?"active":"")" >
                        <a style="margin-left:10px;" href="@(Domain+"/Wallet/FenRunList?state=4")">拒绝</a>
                    </div>
                </div>
                <table class="table">
                    <thead>
                        <tr style="background-color:#8d56e8;color:white;text-align:center">
                            <td>时间</td>
                            <td>备注</td>
                            <td>分润</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <tbody id="thelist"></tbody>
                </table>
            </div>
            <div id="pullUp" style="margin-top:0px">
                <span class="pullUpIcon"></span>
                <span class="pullUpLabel">上拉加载更多...</span>
            </div>
        </div>
    </div>
    <div class="footer">
        <div class="container">
            <div class="row">
                <div class="col-xs-4">
                    <a href="~/shop/index" class="dao">
                        <i class="iconfont icon-shouye-copy-copy-copy" style="color:#246fc0;"></i>
                        <span class="nav_ti" style="color:#246fc0;">首页</span>
                    </a>
                </div>

                <div class="col-xs-4">
                    <a href="~/Wallet/Index" class="dao">
                        <i class="iconfont icon-qianbao-"></i>
                        <span class="nav_ti">钱包</span>
                    </a>
                </div>
                <div class="col-xs-4">
                    <a href="~/UserCenter/UserCenter" class="dao">
                        <i class="iconfont icon-information"></i>
                        <span class="nav_ti">个人中心</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <div id="hiddendIV"></div>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/shop/index.js"></script>
    <script src="~/Scripts/shop/jquery.min.js"></script>
    <script src="~/Scripts/iscroll.js?v=2"></script>
    <script src="~/Content/layerui/layer.js"></script>
    <script type="text/javascript">

            var myScroll,
                pullDownEl,
                pullDownOffset,
                pullUpEl,
                pullUpOffset;

            //todo 自己定义的变量
            var userDataSum,//存储数据的变量
                addNum = 0,
                stepLength =10,//每次加载的步长
                ajaxIndex = 1,
                sumL = 0;//数据的长度
            /**
             *  刷新滚动区域的滚动条的位置（此方法在添加数据后调用）
             **/
            function refreshScrollBar() {
                console.log("刷新滚动条");
                setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!
                    myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
                }, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
            }

            function pullDownAction() {
                console.log("下拉");

                setTimeout(function () {
                    (function reloadPage() {
                        if (GetQueryString("_rf")) {
                            window.location.href = window.location.href.replace(GetQueryString("_rf"), Math.random());
                        } else {
                            window.location.href = window.location.href + (window.location.href.indexOf("?") > -1 ? "&" : "?") + "_rf=" + Math.random();
                        }
                    })();
                    myScroll.refresh();
                    console.log($("#product").height())
                }, 1000);
            }
            //初始化数据
            function pullUpAction() {
                console.log("上拉");

                setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!

                    getData(ajaxIndex, stepLength);
                    myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
                }, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
            }

            function loaded() {
                pullDownEl = document.getElementById('pullDown');
                pullDownOffset = pullDownEl.offsetHeight;
                pullUpEl = document.getElementById('pullUp');
                pullUpOffset = pullUpEl.offsetHeight;
                myScroll = new iScroll('wrapper', {
                    useTransition: true,
                    topOffset: pullDownOffset,
                    onRefresh: function () {
                        if (pullDownEl.className.match('loading')) {
                            pullDownEl.className = '';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';
                        } else if (pullUpEl.className.match('loading')) {
                            pullUpEl.className = '';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
                        }
                    },
                    onScrollMove: function () {
                        if (this.y > 5 && !pullDownEl.className.match('flip')) {
                            pullDownEl.className = 'flip';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';
                            this.minScrollY = 0;
                        } else if (this.y < 5 && pullDownEl.className.match('flip')) {
                            pullDownEl.className = '';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';
                            this.minScrollY = -pullDownOffset;
                        } else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
                            pullUpEl.className = 'flip';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Release to refresh...';
                            this.maxScrollY = this.maxScrollY;
                        } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
                            pullUpEl.className = '';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
                            this.maxScrollY = pullUpOffset;
                        }
                    },
                    onScrollEnd: function () {
                        if (pullDownEl.className.match('flip')) {
                            pullDownEl.className = 'loading';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...';

                            refreshScrollBar();
                            pullDownAction();	// Execute custom function (ajax call?)
                        } else if (pullUpEl.className.match('flip')) {
                            pullUpEl.className = 'loading';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Loading...';
                            if (userDataSum!=0 ) {
                                pullUpAction();	// Execute custom function (ajax call?)

                            } else {
                                pullUpEl.querySelector('.pullUpLabel').innerHTML = "数据已全部加载完毕！";
                            }
                        }
                    }
                });

                setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800);
            }

            document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

            document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);

            function GetQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                return (r != null && r.length >= 2) ? decodeURI(r[2]) : null;
            }

            getData(ajaxIndex, stepLength);

            function getData(index, pagesize) {
                var type = $("#hiddenType").val();
                $.ajax({
                    type: "get",
                    url: "@(ViewBag.DomainUrl + "/Wallet/GetMyFenRunList")" + "?index=" + index + "&pagesize="+pagesize+"&state=@(ViewBag.state)",
                    dataType: "json",
                    success: function (data) {
                        userDataSum = data.Data.length;
                        var datas = "";
                        if (userDataSum != 0) {
                            ajaxIndex++;
                        }
                            for (var i = 0; i < data.Data.length; i++) {
                                datas = datas + BuildDIViitem(data.Data[i]);
                        }

                            $("#thelist").append(datas);
                    }
                })
            }




            function BuildDIViitem(data) {
                var div = '<tr>'+
                    '<td>' + data.StrCreateTime+'</td>'+
                    '<td>' + data.Remarks+'</td>'+
                    '<td>' + data.StrFenRunMoney + '</td>' +
                    '<td id="oper_' + data.UserFenRunId + '">' + Oper(data.IsTiXian, data.OrderFengyunId, data.UserFenRunId, data.AccountBalanceCode) + '</td>' +
                '</tr>';
                return div;
            }
            function Oper(State, OrderFengyunId, UserFenRunId,balanceCode) {
                if (State == 0) {
                    return '<a class="btn btn-success" style="padding:0px;" id="tiian_' + UserFenRunId + '" onclick="TiXian(\'' + OrderFengyunId + '\',\'' + UserFenRunId + '\');">提现</a>'
                        + '<a onclick="Detail(\'' + UserFenRunId + '\');">详细</a>';
                } else if (State ==5) {
                    return '<a onclick="Detail(\'' + UserFenRunId + '\');">审核中</a>';
                } else if (State == 10) {
                    return '<a href="@(ViewBag.DomainUrl)/UserCenter/MyAccountBalance?BalanceCode=' + balanceCode+'">对账</a>';
                }
                return '';
            }

            function Detail(UserFenRunId) {
                $("#hiddendIV").html("");
                $("#hiddendIV").load("@(ViewBag.DomainUrl + "/Wallet/GetFenRunOrderInfo?UserFenRunId=")" + UserFenRunId, '', function () {

                    layer.open({
                        type: 1
                        , content: $("#hiddendIV").html()
                        , anim: 'up'
                        , style: ' bottom:0; left:0; width: 100%; height: 200px; padding:10px 0; border:none;',
                        end: function () {
                            $("#hiddendIV").html("");
                        }
                    });
                });

            }
            function TiXian(OrderFengyunId, UserFenRunId) {
         layer.open({
                    content: '确定提现？'
                    , btn: ['确定', '暂时不要']
                    , yes: function (index) {
                        layer.open({ type: 2, shadeClose: false });
                         $.ajax({
                            type: "post",
                            url: "@(ViewBag.DomainUrl + "/Wallet/ApplyTiXian")",
                            dataType: "json",
                            data: { OrderFengyunId: OrderFengyunId, UserFenRunId: UserFenRunId },
                            success: function (data) {
                                if (data.Success == true) {
                                    layer.closeAll('dialog');
                                    $("#oper_" + UserFenRunId).html("<a>审核中</a>");
                                    layer.open({
                                        content: data.Data
                                        , skin: 'msg'
                                        , time: 2 //2秒后自动关闭
                                        , end: function () {
                                            layer.closeAll('dialog');
                                        }
                                    });
                                } else {
                                    layer.open({
                                        content: data.Data
                                        , skin: 'msg'
                                        , time: 2 //2秒后自动关闭
                                        , end: function () {
                                            layer.closeAll('dialog');
                                        }
                                    });
                                    if (data.Flag != undefined && data.Flag == 1) {
                                        window.location.href = '@(Domain)' +"/UserCenter/BindInfo";
                                    }
                                }
                                }
                        })
                    }
                });
            }
    </script>
</body>

</html>